//Fitra 30th Nov '07 Service inter application list
#define MASTER_APPID									0x0051 //20000
#define DEFAULT_MAG_APP								0x5208
#define MAX_APP											4
#define EMV_ENGINE_ID									96

#define SERVICE_APPREG_CALL 							170
#define SERVICE_HMI_CALL								171
#define SERVICE_EVENTMASTER_CALL						172
#define SERVICE_TEST_CALL								173
#define SERVICE_COMMS									174

#ifdef IMAM_COMMS
#define SERVICE_COMMS_EXCHANGE  						 200 // imam 
#endif

#define SERV_PERSONALISATION				1
#define SERV_VERIFICATION					2

#define ERR_NONE					0
#define ERR_REGISTERAPP			-100

typedef enum{
	EVMSG_NO_EVENT=0,
	EVMSG_FROM_APPLI,
	EVMSG_ASK_MAG_CARD,	
	EVMSG_MAG_CARD,	
	EVMSG_MAN_CARD,	
	EVMSG_AWAKE,
	EVMSG_SMART_CARD,	
	EVMSG_MENU,
	EVMSG_POWER_ON,
	EVMSG_IDLE_APP,
	EVMSG_EMV_PERFORM,
	EVMSG_EMV_PROC,
	EVMSG_EMV_SELECT_AID,
	EVMSG_EMV_SELECT_AID_EXT,	
	EVMSG_SETTLE,
	EVMSG_FALLBACK,
	EVMSG_ISFORYOUAFTER,
	EVMSG_FUNCTION,
	EVMSG_ECR_CALL
}e_eventtype;

typedef struct
{
	int len;
	byte data[128];
	char com_ecr[6];
}ST_ECR_call;

typedef struct
{
	int serviceid;	
	int no;
	DATE ins_date;
	union
	{		
		S_TRANSIN 				in_for_you_after;
		S_SELECT_AID_EXTENDED 	in_select_aid_extended;
		S_SELECT_AID 			in_select_aid;
		S_TRANSIN				in_fall_back;
		S_TRANSIN 				in_debitnonemv;
		ST_ECR_call				in_ecr;
	}par_in;

	union
	{
		S_CARDOUT 				out_for_you_after;
		S_AID_OUT 				out_select_aid_extended;
		S_AID_OUT 				out_select_aid;
		byte 					out_fall_back[256];
		byte						out_debitnonemv;
		ST_ECR_call				out_ecr;
	}par_out;		
} ST_InterApp;

typedef struct{
    	unsigned short apptype;	
	char appname[32];
	e_eventtype evtsupport[50];
	int retval;	
} ST_applist;

typedef struct{
	int totapp;
	ST_applist stap[MAX_APP];	
} ST_appreg;

int Register2Master(byte* regald);

